import React from 'react'
import { Form, Table, Icon, Tag, Modal, Steps, Button, message, Input, Row, Col, Select, DatePicker, InputNumber } from 'antd'
import { DropOption } from 'components'

const Step = Steps.Step;
const confirm = Modal.confirm
const FormItem = Form.Item;
const Option = Select.Option;

class ModalSelect extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			type: '',
			businessType: '',
			createUser: '',
			title: '',
			strTime: '',
			endTime: '',
			auditState: '',

			documentYear: "",
			notarialMatters: "",
			applyName: "",
			createdTime: "",
			notarizationAt: "",
			contractorUserName: "",
			createdUserName: "",

			idcard:"",       //身份证号码
			notaryNumber:"",  //公证号
		};
	}

	searchLeave() {
		const { menu } = this.props
		const params = {
			// documentYear: this.state.documentYear,  //档案年度
			applyName: this.state.applyName,  //申请人姓名

			idcard:this.state.idcard,   //身份证号码

			notarialMatters: this.state.notarialMatters,  //公证事项

			notaryNumber: this.state.notaryNumber,  //公证号

			contractorUserName: this.state.contractorUserName,  //承办人
			createdUserName: this.state.createdUserName,  //建档人
			createdTime: this.state.createdTime,  //收件日期
			notarizationAt: this.state.notarizationAt, //公证日期			
		}
		// const params = {
		// 	type: this.state.type,  //档案类型
		// 	businessType: this.state.businessType,  //业务类型
		// 	createUser: this.state.createUser,  //管理人
		// 	title: this.state.title,   //档案标题
		// 	startTime: this.state.strTime,  //开始时间
		// 	endTime: this.state.endTime,    //结束时间
		// 	auditState: this.state.auditState,  //档案状态
		// 	operatingState: this.props.menu,   //0申请  1审批  2我提交的  3已审批 
		// 	operatingType: 0,  //0归档  1变更  2销毁
		// };
		// if (this.state.documentYear == '') {
		// 	delete params.documentYear
		// }
		if (this.state.idcard == ''){
			delete params.idcard
		}
		if (this.state.notaryNumber == ''){
			delete params.notaryNumber
		}
		if (this.state.notarialMatters == '') {
			delete params.notarialMatters
		}
		if (this.state.applyName == '') {
			delete params.applyName
		}
		if (this.state.createdTime == '') {
			delete params.createdTime
		}
		if (this.state.notarizationAt == '') {
			delete params.notarizationAt
		}
		if (this.state.contractorUserName == '') {
			delete params.contractorUserName
		}
		if (this.state.createdUserName == '') {
			delete params.createdUserName
		}
		// console.log(params)
		params.operatingType = 0
		params.operatingState = menu
		this.props.onSearch(params);
	}
	typeChange(value) {
		this.setState({ documentYear: `${value}` })
	}
	businesChange(event) {
		this.setState({ notarialMatters: event.target.value })
	}
	idCardChange(event) {
		this.setState({ idcard: event.target.value })
	}
	notaryNumberChange(event) {
		this.setState({ notaryNumber: event.target.value })
	}
	userChange1(value) {
		this.setState({ contractorUserName: `${value}` })
	}
	userChange2(value) {
		this.setState({ createdUserName: `${value}` })
	}
	strTimeChange(date, dateString) {
		this.setState({ notarizationAt: dateString });
	}
	endTimeChange(date, dateString) {
		this.setState({ createdTime: dateString });
	}
	userChange(event) {
		this.setState({ applyName: event.target.value })
	}
	stateChange(value) {
		this.setState({ auditState: `${value}` })
		//		this.setState({title:event.target.value})
	}
	titleChage(event) {
		this.setState({ title: event.target.value })
	}
	render() {
		const { getFieldDecorator, getFieldsValue } = this.props.form
		const { depTypes, userList } = this.props
		//		console.log(depTypes)
		//		console.log(userList)
		// console.log(userList)
		const userLists = [];
		for (let i = 0; i < userList.length; i++) {
			userLists.push(<Option key={userList[i].username} value={userList[i].username}>{userList[i].username}</Option>);
		}
		const typeChild = [];
		if (depTypes != undefined) {
			for (let i = 0; i < depTypes.length; i++) {
				typeChild.push(<Option key={depTypes[i].name}>{depTypes[i].name}</Option>);
			}
		}
		const userChild = [];
		if (userList != undefined) {
			for (let i = 0; i < userList.length; i++) {
				userChild.push(<Option key={userList[i].username}>{userList[i].username}</Option>);
			}
		}
		const formItemLayout = {
			labelCol: { span: 6 },
			wrapperCol: { span: 18 },
		};
		const formItemLayout1 = {
			labelCol: { span: 3 },
			wrapperCol: { span: 21 },
		};
		const { current } = this.state;
		return (
			<Form style={{
				border: "1px dashed #e1e1e1", borderRadius: 4, paddingTop: 20, marginBottom: 20
				//margin:" 0 20px",border:" 1px dashed",borderRadius: 5,marginRight:10
			}}>
				<span style={{ marginLeft: 20, fontWeight: 600 }}>查询条件</span>
				<Row style={{ marginTop: 10 }} gutter={24} span={24}>
					{/* <Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
						<span>档案年度:&nbsp;&nbsp;</span>
						<Select
							placeholder="请选择档案年度"
							style={{ width: 200 }}
							onChange={this.typeChange.bind(this)}
						>
							<Option key="" value="">请选择</Option>
							<Option key="2018" value="2018">2018</Option>
							<Option key="2017" value="2017">2017</Option>
							<Option key="2016" value="2016">2016</Option>
							<Option key="2015" value="2015">2015</Option>
							<Option key="2014" value="2014">2014</Option>
							<Option key="2013" value="2013">2013</Option>
							<Option key="2012" value="2012">2012</Option>
							<Option key="2011" value="2011">2011</Option>
							<Option key="2010" value="2010">2010</Option>
							<Option key="2009" value="2009">2009</Option>
							<Option key="2008" value="2008">2008</Option>
							<Option key="2007" value="2007">2007</Option>
							<Option key="2006" value="2006">2006</Option>
							<Option key="2005" value="2005">2005</Option>
							<Option key="2004" value="2004">2004</Option>
							<Option key="2003" value="2003">2003</Option>
							<Option key="2002" value="2002">2002</Option>
							<Option key="2001" value="2001">2001</Option>
							<Option key="2000" value="2000">2000</Option>
						</Select>
					</Col>



					<Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
						<span>审核状态:&nbsp;&nbsp;</span>
						<Select
							style={{ width: 200 }}
							placeholder="请选择档案状态"
							onChange={this.stateChange.bind(this)}
							disabled={true}
						>
							<Option key="" value="">请选择</Option>
							<Option value="0">申请中</Option>
							<Option value="1">通过</Option>
							<Option value="2">拒绝</Option>
						</Select>
					</Col> */}

					<Col lg={6} md={3} sm={4} xs={6} push={1} style={{ marginBottom: 16 }}>
						<span>申请人员:&nbsp;&nbsp;</span>
						<Input
							placeholder="请输入申请人员关键字"
							onChange={this.userChange.bind(this)}
							style={{ width: 200 }}
						/>
					</Col>

					<Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
						<span>身份证号:&nbsp;&nbsp;</span>
						<Input
							placeholder="请输入身份证"
							onChange={this.idCardChange.bind(this)}
							style={{ width: 200 }}
						/>
					</Col>

					<Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
						<span>公证事项:&nbsp;&nbsp;</span>
						{/* <Select
							style={{ width: 200 }}
							placeholder="请选择公证事项"
							onChange={this.businesChange.bind(this)}
						>
							<Option key="公证事项1" value="公证事项1">公证事项1</Option>
							<Option key="公证事项2" value="公证事项2">公证事项2</Option>
							<Option key="公证事项3" value="公证事项3">公证事项3</Option>
							<Option key="公证事项4" value="公证事项4">公证事项4</Option>
							<Option key="公证事项5" value="公证事项5">公证事项5</Option>
						</Select> */}
						<Input
							placeholder="请输入公证事项"
							onChange={this.businesChange.bind(this)}
							style={{ width: 200 }}
						/>
					</Col>

					<Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
						<span>公证号码:&nbsp;&nbsp;</span>
						<Input
							placeholder="请输入公证号"
							onChange={this.notaryNumberChange.bind(this)}
							style={{ width: 200 }}
						/>
					</Col>

					<Col lg={6} md={3} sm={4} xs={6} push={1} style={{ marginBottom: 16 }}>
						<span>承办人员:&nbsp;&nbsp;</span>
						<Select
							style={{ width: 200 }}
							placeholder="请选择承办人"
							onChange={this.userChange1.bind(this)}
						>
							<Option key="" value="">请选择</Option>
							{userLists}
						</Select>
					</Col>
					<Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
						<span>建档人员:&nbsp;&nbsp;</span>
						<Select
							style={{ width: 200 }}
							placeholder="请选择建档人"
							onChange={this.userChange2.bind(this)}
						>
							<Option key="" value="">请选择</Option>
							{userLists}
						</Select>
					</Col>
					<Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }}>
						<span>收件日期:&nbsp;&nbsp;</span>
						<DatePicker
							style={{ width: 200 }}
							placeholder="收件日期"
							onChange={this.endTimeChange.bind(this)}
							showTime
							format="YYYY-MM-DD"
						/>
					</Col>
					<Col lg={6} md={3} sm={4} xs={6} style={{ marginBottom: 16 }} >
						<span>公证日期:&nbsp;&nbsp;</span>
						<DatePicker
							style={{ width: 200 }}
							placeholder="公证日期"
							onChange={this.strTimeChange.bind(this)}
							showTime
							format="YYYY-MM-DD"
						/>
					</Col>
					
					<Col lg={24} md={12} sm={16} xs={24} style={{ marginBottom: 16, textAlign: "center" }}>
						<Button
							style={{ marginLeft: 10, width: 200, height: 30 }}
							type="primary"
							size="default"
							onClick={this.searchLeave.bind(this)}
						>
							查询
            			</Button>
					</Col>

				</Row>

			</Form>
		)
	}


}

export default Form.create()(ModalSelect)
